﻿using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;

namespace Cloak.Mvp
{
	/// <summary>
	/// Describes a context which governs the lifetime of presenter instances
	/// </summary>
	[ContractClass(typeof(IPresenterContextContract))]
	public interface IPresenterContext
	{
		/// <summary>
		/// Creates a presenter to take effect at the specified usage site
		/// </summary>
		/// <param name="site">The usage of the presenter</param>
		/// <returns>The presenter instance</returns>
		object CreatePresenter(PresenterSite site);
	}

	[ContractClassFor(typeof(IPresenterContext))]
	internal abstract class IPresenterContextContract : IPresenterContext
	{
		object IPresenterContext.CreatePresenter(PresenterSite site)
		{
			Contract.Requires(site != null);
			Contract.Ensures(Contract.Result<object>() != null);

			return null;
		}
	}
}